home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / kerberos / pc / krb_libk.lha / Lib / KRB / EXT_TKT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-31  |  1.8 KB  |  61 lines

  1. /*
  2.  * $Source: /mit/kerberos/src/lib/krb/RCS/extract_ticket.c,v $
  3.  * $Author: shanzer $
  4.  *
  5.  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
  6.  * of Technology.
  7.  *
  8.  * For copying and distribution information, please see the file
  9.  * <mit-copyright.h>.
  10.  */
  11.  
  12. #ifndef lint
  13. static char *rcsid_extract_ticket_c =
  14. "$Header: extract_ticket.c,v 4.6 88/10/07 06:08:15 shanzer Exp $";
  15. #endif /* lint */
  16.  
  17. #include <mit_copy.h>
  18. #include <krb.h>
  19. #include <prot.h>
  20. #include <string.h>
  21.  
  22. /*
  23.  * This routine is obsolete.
  24.  *
  25.  * This routine accepts the ciphertext returned by kerberos and
  26.  * extracts the nth ticket.  It also fills in the variables passed as
  27.  * session, liftime and kvno.
  28.  */
  29.  
  30. extract_ticket(cipher,n,session,lifetime,kvno,realm,ticket)
  31.     KTEXT cipher;        /* The ciphertext */
  32.     int n;            /* Which ticket */
  33.     char *session;        /* The session key for this tkt */
  34.     int *lifetime;        /* The life of this ticket */
  35.     int *kvno;            /* The kvno for the service */
  36.     char *realm;        /* Realm in which tkt issued */
  37.     KTEXT ticket;        /* The ticket itself */
  38. {
  39.     char *ptr;
  40.     int i;
  41.  
  42.     /* Start after the ticket lengths */
  43.     ptr = (char *) cipher->dat;
  44.     ptr = ptr + 1 + (int) *(cipher->dat);
  45.  
  46.     /* Step through earlier tickets */
  47.     for (i = 1; i < n; i++)
  48.     ptr = ptr + 11 + strlen(ptr+10) + (int) *(cipher->dat+i);
  49.     bcopy(ptr, (char *) session, 8); /* Save the session key */
  50.     ptr += 8;
  51.     *lifetime = *(ptr++);    /* Save the life of the ticket */
  52.     *kvno = *(ptr++);        /* Save the kvno */
  53.     (void) strcpy(realm,ptr);    /* instance */
  54.     ptr += strlen(realm) + 1;
  55.  
  56.     /* Save the ticket if its length is non zero */
  57.     ticket->length = *(cipher->dat+n);
  58.     if (ticket->length)
  59.     bcopy(ptr, (char *) (ticket->dat), ticket->length);
  60. }
  61.